<?php

ob_start();
session_cache_expire(999999999);
if (!isset($_SESSION)) {
    session_start();
}

include 'operations/connection.php';
$q = mysql_query("SELECT c.IDLog FROM checklogtime c WHERE c.IDEmployee='" . $_SESSION['IDEmployee'] . "' ORDER BY IDLog DESC LIMIT 0,1");

$row = mysql_fetch_array($q);

mysql_query("UPDATE checklogtime SET TimeLogOut=NOW() WHERE IDLog=" . $row['IDLog']);

mysql_close($connection);
session_unregister('IDEmployee');
session_unregister('user');
session_unregister('fullname');
session_unregister('role');
//session_destroy();
setcookie('IDEmployee');
//setcookie('user'); 
//setcookie('fullname'); 
//setcookie('role'); 
//setcookie('curLanguage');

header('Location: login.php');

ob_flush();
?>